package br.com.character.flex.chorm.core.sql
{
    import mx.collections.ArrayCollection;

    [Bindable]
    public class Table implements ITable
    {
        private var _name:String;
        private var _alias:String;
        private var _fields:ArrayCollection;
        
        public function Table(fs:ArrayCollection, n:String, a:String=null)
        {
            _name = n;
            _alias= a;
            _fields = fs;
        }
        
        public function get fields():ArrayCollection
        {
            return _fields;
        }

        public function set fields(value:ArrayCollection):void
        {
            _fields = value;
        }

        public function get name():String
        {
            return _name;
        }
        
        public function set name(param:String):void
        {
            _name = param;
        }
        
        public function get alias():String
        {
            return _alias;
        }
        
        public function set alias(param:String):void
        {
            _alias = param;
        }
        
        public function toSQL():String {
            var result:String = name;
            if(alias!=null){
                result += " " + alias;
            }
            return result;
        }
    }
}